package com.bwie.task;

import com.bwie.mapper.TbProdMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/6/25 16:54
 * @Version 1.0
 */
@Component
public class ProdTask {

    @Autowired
    TbProdMapper tbProdMapper;

    /**
     * 每分钟检查一次商品上架
     */
    @Scheduled(cron = "0 0/1 * * * ?")
    public void uploadProdTask(){
        System.out.println("开始执行定时上架任务");
        tbProdMapper.taskUploadProd();
        System.out.println("执行成功定时上架任务");
    }

    /**
     * 每分钟检查一次商品下架
     */
    @Scheduled(cron = "0 0/1 * * * ?")
    public void taskOfflineProd(){
        System.out.println("开始执行定时下架任务");
        tbProdMapper.taskOfflineProd();
        System.out.println("执行结束定时下架任务");
    }

}
